import cv2

img = cv2.imread('img/dogs.png')
# cv2.imshow('', img)
# 等待用户选择区域，返回左上角坐标及宽高
roi = cv2.selectROI('select redgion', img, False)
print(roi)
x, y, w, h = roi
# 截取行列
roi_img = img[y:y+h, x:x+w]
cv2.imshow('', roi_img)
cv2.waitKey(0)